export default {
  toThousands(str) {
    if (!str && String(str) !== "0") return;
    if (String(str).indexOf(".") === -1) {
      return String(str).replace(/(\d)(?=(?:\d{3})+$)/g, "$1,") + ".00";
    } else {
      let sp = String(str).split(".");
      return `${sp[0].replace(/(\d)(?=(?:\d{3})+$)/g, "$1,")}.${sp[1]}`;
    }
  },
  numberFormat(num) {
    const options = {
      style: "currency",
      currency: "CNY",
      currencyDisplay: "symbol", // symbol, name, code,
    };
    const numberFormat = new Intl.NumberFormat("zh-CN", options);
    return numberFormat.format(num);
  },
  void(str) {
    return str || "";
  },
};
